
AUTHOR  = 'kishore reddy'
COMPANY = 'codehelix solutions inc.'
URL     = 'www.codehelixsolutions.com'
URL2    = 'http://fluentscript.codeplex.com'
DOC     = 'http://fluentscript.codeplex.com/documentation'


compiler_plugin "FS.Plugins.Ext.DateNamed"
{
	desc            =   "Allows representation of dates used calendar names such as Jan 1 2012, or January 1st 2012"
	examples        =   [ 'jan 1st', 'Jan 1st', 'Jan 1', 'Jan 1 2012', 'Jan 1st 2012', 'January 1st, 2012' ]	
	type            =   "expr"
	precedence	    =   1	
	grammer_match   =   "@starttoken @number"
	grammer_parse   =   "$month:@starttoken.value $day:@number $dayend:( st | nd | rd | th )? ( ','?  $year:@number )?"	
	arg_defaults    =   {  "year-value" : new Date().getFullYear() }	
	start_tokens    =   {  "jan"	    : 1,  "feb"	     : 2, "mar"   : 3, 	  "apr"   : 4,	"may" : 5, 		"jun"  : 6, 	"jul"  : 7, 	"aug"    : 8,	"sep"	    : 9,	"oct"     : 10,  "nov"      : 11, "dec"      : 12,             
					       "Jan"	    : 1,  "Feb"	     : 2, "Mar"   : 3, 	  "Apr"   : 4,	"May" : 5, 		"Jun"  : 6, 	"Jul"  : 7, 	"Aug"    : 8,	"Sep"	    : 9,	"Oct"     : 10,  "Nov"      : 11, "Dec"      : 12,
					       "january"    : 1,  "february" : 2, "march" : 3,    "april" : 4, 	"may" : 5,      "june" : 6,     "july" : 7,     "august" : 8,   "september" : 9,	"october" : 10,  "november" : 11, "december" : 12,
					       "January"    : 1,  "February" : 2, "March" : 3,    "April" : 4, 	"May" : 5,      "June" : 6,     "July" : 7,     "August" : 8,   "September" : 9,	"October" : 10,  "November" : 11, "December" : 12 
					    }
						
	parse           = function(args)	
	{		
		var month = args["month-value"];
		var day = args["day-value"];
		var year = args["year-value"];
		return compiler.to_constant_date(month, day, year)
	}
}


// plugin for and/or being used for && and || respectively
compiler_plugin "FS.Plugins.Ext.Day"
{
	desc            =   "Allows representation of days"
	examples        =   [ 'monday', 'Monday', 'tuesday', 'Tuesday' ]	
	type            =   "expr"
	precedence	    =   1	
	grammer_match   =   "@starttoken"
	grammer_parse   =   "$daynumber:@starttoken.value"		
	start_tokens    =   {
							"monday" : 1, "tuesday" : 2, "wednesday" : 3, "thursday" : 4, "friday" : 5, "saturday" : 6, "sunday" : 7,
							"Monday" : 1, "Tuesday" : 2, "Wednesday" : 3, "Thursday" : 4, "Friday" : 5, "Saturday" : 6, "Sunday" : 7
						}
	parse           = function(args)	
	{		
		return compiler.to_const_day(args["daynumber"]);
	}
}




// plugin for and/or being used for && and || respectively
function FS_Plugins_Ext_AndOr()
{
	this.fullName        =   "FS.Plugins.Ext.AndOr";
	this.desc            =   "Allows representation of logical and/or conditions using words 'and'/'or'";
	this.examples        =   [ 'and', 'or' ];	
	this.type            =   "token";
	this.precedence      =   1;	
	this.start_tokens    =   [ 
								[ "and" , "&&" ], 
								[ "or"  , "||" ] 
							 ];
}

// plugin for and/or being used for && and || respectively
function FS_Plugins_Ext_Bool()
{
	this.fullname		 =   "FS.Plugins.Ext.Bool";
	this.desc            =   "Allows representation of boolean operators such as true/false in other formats";
	this.examples        =   [ "yes", "no" ];	
	this.type            =   "token";
	this.precedence      =   1;	
	this.start_tokens    =   [  
								["yes" , "true" ],  
								["Yes" , "true" ],  
								["on"  , "true" ],  
								["On"  , "true" ],
								["no"  , "false"],  
								["No"  , "false"],  
								["off" , "false"],  
								["Off" , "false"]
							 ];
}

// plugin for and/or being used for && and || respectively
function FS_Plugins_Ext_Compare()
{
	this.fullname		 =   "FS.Plugins.Ext.Compare";
	this.desc            =   "Allows representation of compare operators such as '<' and '>' using words 'more than' and 'less than'";
	this.examples        =   [ "yes", "no" ];	
	this.type            =   "token";
	this.isStatement     =   false;
	this.isEOSRequired   =   false;
	this.precedence      =   1;	
	this.start_tokens    =   {  
								[ "less than"              , 	"<" 	], 
								[ "before"                 , 	"<" 	],
								[ "below"                  , 	"<" 	],
								[ "is below"               , 	"<" 	],
								[ "is before"              , 	"<" 	],
								[ "is less than"           , 	"<" 	],
								[ "more than"              , 	">" 	],
								[ "after"                  , 	">" 	],
								[ "above"                  , 	">" 	],
								[ "is after"               , 	">" 	],
								[ "is above"               , 	">" 	],
								[ "is more than"           , 	">" 	],
								[ "less than equal"        , 	"<="	],
								[ "less than equal to"     , 	"<="	],
								[ "is less than equal to"  , 	"<="	],
								[ "more than equal"        , 	">="	],
								[ "more than equal to"     , 	">="	],
								[ "is more than equal to"  , 	">="	],
								[ "is"                     , 	"=="	],
								[ "is equal"               , 	"=="	],
								[ "is equal to"            , 	"=="	],
								[ "equals"                 , 	"=="	],
								[ "equal to"               , 	"=="	],
								[ "not"                    , 	"!="	],
								[ "not equal"              , 	"!="	],
								[ "not equal to"           , 	"!="	],
								[ "is not"                 , 	"!="	],
								[ "is not equal to"        , 	"!="    ]
							 };
}


// plugin for and/or being used for && and || respectively
function FS_Plugins_Ext_Time()
{
	this.desc            =   "Allows representation of time using clock format";
	this.examples        =   [ '8 am', '12 pm', '7:45 am', '3:15:10 pm' ];	
	this.type            =   "expr";
	this.precedence      =   1;	
	this.grammar_parse   =   "$hour:@starttoken.value ( $sepMin:: $minutes:@number )? ( $sepSec:: $seconds:@number )? $ampm:( am | pm )";			
	this.start_tokens    =   {	"@number" : "@number" };
	this.parse           =  function(args)
	{		
		return metacompiler.ToConstTime( args["daynumber-value"], args["daynumber"] );
	}
}


// plugin for and/or being used for && and || respectively
function FS_Plugins_Ext_Day()
{
	desc            =   "Allows representation of days using day names";
	examples        =   [ 'monday', 'Monday', 'tuesday', 'Tuesday' ];
	type            =   "expr";
	precedence      =   1;	
	grammar_parse   =   "$daynumber:@starttoken.value";			
	start_tokens    =   {
							"sunday" : 0, "monday" : 1, "tuesday" : 2, "wednesday" : 3, "thursday" : 4, "friday" : 5, "saturday" : 6, 
							"Sunday" : 0, "Monday" : 1, "Tuesday" : 2, "Wednesday" : 3, "Thursday" : 4, "Friday" : 5, "Saturday" : 6, 
							"sun"    : 0, "mon"    : 1, "tues"    : 2, "wed"       : 3, "thurs"    : 4, "fri"    : 5, "sat"      : 6, 
							"Sun"    : 0, "Mon"    : 1, "Tues"    : 2, "Wed"       : 3, "Thurs"    : 4, "Fri"    : 5, "Sat"      : 6 
						};
	parse           =  function(args)
	{		
		return metacompiler.ToConstDay( args["daynumber-value"], args["daynumber"] );
	}
}















